package com.artezio.buyndrive.domain;

import java.io.Serializable;
import javax.persistence.*;


@Entity
@Table(name = "applicability_parts")

//Применимость запчастей
public class ApplicabilityParts implements Serializable {
    private static final long serialVersionUID = 1L;
    
    //Составной ключ(мадификация, запчасть)
    @EmbeddedId
    protected ApplicabilityPartsPK applicabilityPartsPK;
    
    //Начало выпуска
    @Column(name = "first_year")
    private Integer firstYear;
    
    //Окончание выпуска
    @Column(name = "last_year")
    private Integer lastYear;
    
    @JoinColumn(name = "id_parts", referencedColumnName = "id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Parts parts;
    
    @JoinColumn(name = "id_car_modification", referencedColumnName = "id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private CarModification carModification;

    public ApplicabilityParts() {
    }

    public ApplicabilityParts(ApplicabilityPartsPK applicabilityPartsPK) {
        this.applicabilityPartsPK = applicabilityPartsPK;
    }

    public ApplicabilityParts(Long idCarModification, Long idParts) {
        this.applicabilityPartsPK = new ApplicabilityPartsPK(idCarModification, idParts);
    }

    public ApplicabilityPartsPK getApplicabilityPartsPK() {
        return applicabilityPartsPK;
    }

    public void setApplicabilityPartsPK(ApplicabilityPartsPK applicabilityPartsPK) {
        this.applicabilityPartsPK = applicabilityPartsPK;
    }

    public Integer getFirstYear() {
        return firstYear;
    }

    public void setFirstYear(Integer firstYear) {
        this.firstYear = firstYear;
    }

    public Integer getLastYear() {
        return lastYear;
    }

    public void setLastYear(Integer lastYear) {
        this.lastYear = lastYear;
    }

    public Parts getParts() {
        return parts;
    }

    public void setParts(Parts parts) {
        this.parts = parts;
    }

    public CarModification getCarModification() {
        return carModification;
    }

    public void setCarModification(CarModification carModification) {
        this.carModification = carModification;
    }

}
